package com.mofang.activity.interact;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.mofang.R;
import com.mofang.activity.BaseTitleViewActiviey;
import com.mofang.utils.LoanCalculate;

public class LoanCalculateResultActivity extends BaseTitleViewActiviey {

	private Intent data;
	private LoanCalculate calculate;
	private TextView calculate_result_paymentMethod_text;
	private TextView tv_gjj_sum;
	private TextView tv_syj_sum;
	private TextView tv_gjj_profit;
	private TextView tv_syj_profit;
	private TextView tv_payprofit_all;
	private TextView tv_pay_per_month;
	private TextView tv_year_length;

	private LinearLayout ll_gjj_sum;
	private LinearLayout ll_syj_sum;
	private LinearLayout ll_syj_profit;
	private LinearLayout ll_gjj_profit;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		getData();
	}

	private void getData() {
		data = getIntent();
		// 返回计算
		calculate = (LoanCalculate) data.getSerializableExtra("calculate");
		calculate = calculate.calculate();
		// 显示计算结果
		tv_year_length.setText(calculate.getLc_yearLongth() + "年" + "("
				+ calculate.getLc_yearLongth() * 12 + "期)");
		tv_payprofit_all.setText(calculate.getPayProfit() + "元");
		if (calculate.getRepayment() == LoanCalculate.Repay_debx) {
			calculate_result_paymentMethod_text.setText("等额本息");
		} else {
			calculate_result_paymentMethod_text.setText("等额本金");
		}
		int model = calculate.getLendingModel();
		tv_pay_per_month.setText(calculate.getPayPermonth() + "元");
		switch (model) {
		case LoanCalculate.Gjj_loan:
			ll_syj_sum.setVisibility(View.GONE);
			ll_syj_profit.setVisibility(View.GONE);
			tv_gjj_profit.setText(calculate.getLc_gjjProfit() + "");
			tv_gjj_sum.setText(calculate.getLc_gjjtotal() + "");
			break;
		case LoanCalculate.Sy_loan:
			ll_gjj_sum.setVisibility(View.GONE);
			ll_gjj_profit.setVisibility(View.GONE);
			tv_syj_profit.setText(calculate.getLc_syjProfit() + "");
			tv_syj_sum.setText(calculate.getLc_syjtotal() + "");
			break;

		case LoanCalculate.Group_loan:
			tv_gjj_profit.setText(calculate.getLc_gjjProfit() + "");
			tv_gjj_sum.setText(calculate.getLc_gjjtotal() + "");
			tv_syj_profit.setText(calculate.getLc_syjProfit() + "");
			tv_syj_sum.setText(calculate.getLc_syjtotal() + "");
			break;
		default:
			break;
		}

	}

	@Override
	protected void initView() {
		setContentView(R.layout.activity_loan_calculate_result);
		setNavigationTitle("税费计算器");
		setNavigationLeftBtnImage(R.drawable.return_arrow);
		calculate_result_paymentMethod_text = (TextView) findViewById(R.id.calculate_result_paymentMethod_text);
		tv_gjj_sum = (TextView) findViewById(R.id.tv_gjj_sum);
		tv_syj_sum = (TextView) findViewById(R.id.tv_syj_sum);
		tv_gjj_profit = (TextView) findViewById(R.id.tv_gjj_profit);
		tv_syj_profit = (TextView) findViewById(R.id.tv_syj_profit);
		tv_payprofit_all = (TextView) findViewById(R.id.tv_payprofit_all);
		tv_pay_per_month = (TextView) findViewById(R.id.tv_pay_per_month);
		tv_year_length = (TextView) findViewById(R.id.tv_year_length);
		ll_gjj_sum = (LinearLayout) findViewById(R.id.ll_gjj_sum);
		ll_syj_sum = (LinearLayout) findViewById(R.id.ll_syj_sum);
		ll_gjj_profit = (LinearLayout) findViewById(R.id.ll_gjj_profit);
		ll_syj_profit = (LinearLayout) findViewById(R.id.ll_syj_profit);
	}

}
